<template>
  <view class="page payment-page">
    <view class="payment-header">
      <view class="back-btn" @click="cancelPayment">
        <text class="back-icon">←</text>
      </view>
      <text class="payment-title">解锁完整报告</text>
      <view class="placeholder"></view>
    </view>
    
    <view class="payment-content">
      <view class="report-preview">
        <text class="preview-title">您将解锁的内容</text>
        <view class="preview-items">
          <view class="preview-item">
            <text class="preview-icon">✅</text>
            <text class="preview-text">完整职场分析</text>
          </view>
          <view class="preview-item">
            <text class="preview-icon">✅</text>
            <text class="preview-text">详细发展建议</text>
          </view>
          <view class="preview-item">
            <text class="preview-icon">✅</text>
            <text class="preview-text">恋爱分析</text>
          </view>
          <view class="preview-item">
            <text class="preview-icon">✅</text>
            <text class="preview-text">荣格八维解析</text>
          </view>
        </view>
      </view>
      
      <view class="payment-amount-container">
        <!-- <text class="original-price">原价 ¥69.9</text>
        <text class="discount-tag">限时优惠</text> -->
        <text class="payment-amount">¥{{ price }}</text>
      </view>
      
      <view class="payment-methods">
        <text class="methods-title">请选择支付方式</text>
        <view class="method-list">
          <view 
            class="payment-method" 
            :class="{ selected: selectedPaymentMethod === 'wechat' }"
            @click="selectPaymentMethod('wechat')"
          >
            <text class="method-icon">💬</text>
            <text class="method-name">微信支付</text>
            <text class="method-recommend">推荐</text>
          </view>
        </view>
      </view>
    </view>
    
    <view class="payment-actions">
      <button 
        class="confirm-pay-btn" 
        @click="changeConfirmPayment"
      >
        确认支付 ¥{{ price }}
      </button>
    </view>
  </view>
</template>

<script>
export default {
  name: 'PaymentPage',
  props: {
    selectedPaymentMethod: {
      type: String,
      default: ''
    },
    price: {
      type: [String, Number],
      default: "19.9"
    },
    testResultId: {
      type: [String, Number],
      default: null
    },
    userId: {
      type: [String, Number],
      default: null
    }
  },
  mounted() {
    console.log('PaymentPage mounted with props:', {
      testResultId: this.testResultId,
      userId: this.userId,
      selectedPaymentMethod: this.selectedPaymentMethod,
      price: this.price
    });
  },
  methods: {
    changeConfirmPayment(){
     
      console.log('PaymentPage changeConfirmPayment method called');
        this.$emit('confirm-payment');
    },
    selectPaymentMethod(method) {
      console.log('PaymentPage selectPaymentMethod method called with:', method);
      this.$emit('select-payment-method', method);
    },
    confirmPayment() {
      console.log('PaymentPage confirmPayment method called');
      console.log('Props:', {
        testResultId: this.testResultId,
        userId: this.userId,
        selectedPaymentMethod: this.selectedPaymentMethod,
        price: this.price
      });
      this.$emit('confirm-payment');
    },
    cancelPayment() {
      this.$emit('cancel-payment');
    },
    
  }
}
</script>

<style scoped>
/* 支付页面样式 */
.payment-page {
  background-image: url('https://hongcat-beta.oss-cn-chengdu.aliyuncs.com/bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  padding: 0;
  position: relative;
}

.payment-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 1;
}

.payment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30rpx 40rpx;
  /* background-color: white; */
  /* box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.1); */
  position: relative;
  z-index: 2;
  padding-top: 53px;
}

.payment-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
}

.payment-content {
  padding: 40rpx;
  position: relative;
  z-index: 2;
}

.report-preview {
  background-color: white;
  border-radius: 20rpx;
  padding: 40rpx;
  margin-bottom: 40rpx;
  box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.05);
}

.preview-title {
  font-size: 34rpx;
  font-weight: bold;
  color: #333;
  display: block;
  margin-bottom: 30rpx;
  text-align: center;
}

.preview-items {
  display: flex;
  flex-direction: column;
  gap: 25rpx;
}

.preview-item {
  display: flex;
  align-items: center;
}

.preview-icon {
  font-size: 32rpx;
  color: #4caf50;
  margin-right: 20rpx;
}

.preview-text {
  font-size: 28rpx;
  color: #666;
}

.payment-amount-container {
  text-align: center;
  margin-bottom: 50rpx;
}

.original-price {
  font-size: 28rpx;
  color: #999;
  text-decoration: line-through;
  display: block;
  margin-bottom: 10rpx;
}

.discount-tag {
  background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 50%);
  color: #333;
  padding: 5rpx 15rpx;
  border-radius: 10rpx;
  font-size: 24rpx;
  margin-right: 20rpx;
}

.payment-amount {
  font-size: 70rpx;
  font-weight: bold;
  color: #ff6b6b;
}

.payment-methods {
  background-color: white;
  border-radius: 20rpx;
  padding: 40rpx;
  box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.05);
}

.methods-title {
  font-size: 32rpx;
  color: #333;
  display: block;
  margin-bottom: 30rpx;
  text-align: center;
}

.method-list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.payment-method {
  display: flex;
  align-items: center;
  height: 110rpx;
  background-color: #f8f9fa;
  border: 2rpx solid #e9ecef;
  border-radius: 15rpx;
  padding: 0 30rpx;
}

.payment-method.selected {
  border-color: #007aff;
  background-color: #e6f1ff;
}

.method-icon {
  font-size: 40rpx;
  margin-right: 20rpx;
}

.method-name {
  flex: 1;
  font-size: 32rpx;
  color: #333;
}

.method-recommend {
  background-color: #ffd700;
  color: #333;
  padding: 5rpx 15rpx;
  border-radius: 10rpx;
  font-size: 24rpx;
}

.payment-actions {
  padding: 0 40rpx 40rpx;
}

.confirm-pay-btn {
  width: 100%;
  height: 100rpx;
  background: linear-gradient(45deg, #ff6b6b 0%, #ff8e8e 100%);
  color: white;
  border: none;
  border-radius: 15rpx;
  font-size: 36rpx;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6rpx 20rpx rgba(255, 107, 107, 0.3);
  position: relative;
  z-index: 2;
}

.confirm-pay-btn[disabled] {
  background: #cccccc;
  box-shadow: none;
}

/* 添加测试按钮样式 */
.payment-actions button {
  margin-top: 20rpx;
}
</style>